package be.bonamis.umpire.ui.server.utils;

import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.stereotype.Service;

@Service
public class UtilsContextAware implements ApplicationContextAware {

	public static ApplicationContext applicationContext = null;

	public static ApplicationContext getApplicationContext() {
		return applicationContext;
	}

	@Override
	public void setApplicationContext(ApplicationContext applicationContext)
			throws BeansException {
		this.applicationContext = applicationContext;
	}

	public static Object getBean(String nameBean) {
		return applicationContext.getBean(nameBean);
	}

	public static <T> T getBeanByType(Class<T> clazz) {
		return applicationContext.getBean(clazz);
	}

}
